#include "PC.hpp"
#include <unistd.h>
int cnt = 0;
void* Producer(void* args)
{
    BlockQueue<int>* bq = (BlockQueue<int>*)(args);
    while(true)
    {
        bq->Equeue(cnt);
        std::cout << "生产了一个任务 " << cnt <<std::endl;
        cnt++;
    }
    return nullptr;
}


void* Consumer(void* args)
{
    BlockQueue<int>* bq = (BlockQueue<int>*)(args);
    while(true)
    {
        sleep(3);
        int task = bq->Pop();
        std::cout <<  "消费了一个任务" << task <<std::endl;
    }
    return nullptr;
}

int main()
{
    BlockQueue<int> bq;
    pthread_t producer;
    pthread_t consumer;

    pthread_create(&producer , nullptr , Producer , (void*)&bq);
    pthread_create(&consumer , nullptr , Consumer , (void*)&bq);

    pthread_join(producer , nullptr);
    pthread_join(consumer , nullptr);
    return 0;
}